#include "PrecompiledHeader.h"
#include "RootNode.h"

/*--------------------------------------------------------------------------*/

RootNode::RootNode(const NodeCreation& nc) :
	INode(nc.m_flags | ENodeFlag::NoParent, nc.m_parent, nc.m_scene)
{
	AssertLogC(nc.m_parent != NULL, "Trying to set !NULL as parent for root");
	/*--------------------------------------------------------------------------*/

	RenderTaskDesc desc;
	desc.m_material = g_Material->GetMaterial("mat_geometry");
	desc.m_argument = 0;
	desc.m_flags = 0;
	desc.m_priority = 0;
	desc.m_object = this;

	this->AddRenderTask(desc);

	/*--------------------------------------------------------------------------*/

	this->SetOcclusionTestEnabled(false);
	this->SetFrustumTestEnabled(false);

	this->SetName("Root");
	this->SetRadius(FLT_MAX);
}

/*--------------------------------------------------------------------------*/

RootNode::~RootNode()
{

}

/*--------------------------------------------------------------------------*/

uint RootNode::TreeCalc(uint arg)
{
	__super::TreeCalc();

	this->BindRenderTask(this->GetSceneInstance()->GetRenderPhase(), 0);
	return 0;
}

/*--------------------------------------------------------------------------*/

void RootNode::OnRender(const RenderTask* renderTask, uint camarg)
{
	switch (renderTask->GetArgument())
	{
	case 0:
	{
// 		OpenGL::DrawLine(glm::vec3(-100000.0f, 0.0f, 0.0f), glm::vec3(100000.0f, 0.0f, 0.0f), Color::Red, Color::Red);
// 		OpenGL::DrawLine(glm::vec3(0.0f, -100000.0f, 0.0f), glm::vec3(0.0f, 100000.0f, 0.0f), Color::Green, Color::Green);
// 		OpenGL::DrawLine(glm::vec3(0.0f, 0.0f, -100000.0f), glm::vec3(0.0f, 0.0f, 100000.0f), Color::Blue, Color::Blue);

		break;
	}
	}

}

/*--------------------------------------------------------------------------*/